home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / cljune86.zip / STOOLS1.LTG < prev    next >
Text File  |  1986-03-31  |  2KB  |  54 lines

  1.  
  2.                             Listing 1
  3.  
  4. #include "stdio.h"
  5.  
  6. /******************************************************************************/
  7. /*---------------------------- The TOUCH utility -----------------------------*/è/******************************************************************************/
  8. /*                                                                            */
  9. /*  Name: bump                           Version: 1.0                         */
  10. /*                                                                            */
  11. /*  Last Edit: 03/21/86                  Compiler: Lattice C, v2.15d          */
  12. /*                                                                            */
  13. /*  Purpose:  Change a file or list of files time and date stamp to the       */
  14. /*            current date and time.                                          */
  15. /*                                                                            */
  16. /******************************************************************************/
  17. /*------------------ Copyright 1985 & 1986, by Gary Elfring ------------------*/
  18. main(argc,argv)
  19.     int        argc;
  20.     char    *argv[];
  21.     {
  22.     extern    FILE    *fopen();
  23.     FILE    *ptr;
  24.     int        i;
  25.     char    buf[2];
  26.  
  27. /*---------- If only one argument, tell them how to use the program ----------*/
  28.     if (argc == 1)
  29.         {
  30.         printf("USE --> touch file1.ext file2.ext ... fileN.ext{cr}\n");
  31.         exit(1);
  32.         }
  33.  
  34. /*------------------------- For each passed argument -------------------------*/
  35.     for (i = 1; i < argc; ++i)
  36.         {
  37.         /*-------------------- Open the file for read / write --------------------*/
  38.         if ((ptr = fopen(argv[i],"rb+")) == NULL)
  39.             {
  40.             printf("Error: can not open %s\n",argv[i]);
  41.             exit(2);
  42.             }
  43.         /*---------------------------- Read in 1 byte ----------------------------*/
  44.         fread(buf,1,1,ptr);
  45.         /*-------------- Rewind the file pointer back to beginning ---------------*/
  46.         fseek(ptr,0L,0);
  47.         /*-------------- Write the byte out (force redate of file) ---------------*/
  48.         fwrite(buf,1,1,ptr);
  49.         /*----------------- Close the file and move to the next ------------------*/
  50.         fclose(ptr);
  51.         }
  52.     }
  53.